import Vue from "vue";
import VueRouter from "vue-router";

if (process.env.NODE_ENV === "development") {
    Vue.use(VueRouter);
}

import { ROUTER_MODE } from "../config/app";

import Home from "../views/home/index.vue";
import ExtraApply from "../views/dnf/extraApply.vue";

// 管理组相关
import adminRouter from "../views/userManage/admin/router.vue";
import authAdmin from "../views/userManage/admin/authAdmin.vue";
import authRole from "../views/userManage/admin/authRole.vue";
import authPermissionRule from "../views/userManage/admin/authPermissionRule.vue";

// 上传相关
import tinymce from "../views/components/tinymce-demo.vue";
import upload from "../views/components/upload-demo.vue";

// 广告管理
import goldCoinProxy from "../views/dnf/goldCoinProxy.vue";
import goldCoinSelf from "../views/dnf/goldCoinSelf.vue";
import jadeProxy from "../views/dnf/JadeProxy.vue";
import jadeSelf from "../views/dnf/JadeSelf.vue";
import training from "../views/dnf/training.vue";
import goldCoinMd from "../views/dnf/goldCoinMd.vue";
import order from "../views/dnf/order.vue";
import order2 from "../views/dnf/order2.vue";
import order3 from "../views/dnf/order3.vue";
import total from "../views/dnf/Total.vue";
import goldCoinShop from "@/views/dnf/goldCoinShop.vue";
import goldCoinS1 from "@/views/dnf/goldCoinS1.vue";
import goldCoinS2 from "@/views/dnf/goldCoinS2.vue";
import goldCoinS3 from "@/views/dnf/goldCoinS3.vue";
import goldCoinS4 from "@/views/dnf/goldCoinS4.vue";
import goldCoinMdProxy from "@/views/dnf/goldCoinMdProxy.vue";
import orderMd from "@/views/dnf/orderMd.vue";
import orderMdProxy from "@/views/dnf/orderMdProxy.vue";
import goldCoinMd2 from "@/views/dnf/goldCoinMd2.vue";
import orderMd2 from "@/views/dnf/orderMd2.vue";
import orderJade from "@/views/dnf/orderJade.vue";
import orderJadeSelf from "@/views/dnf/orderJadeSelf.vue";
import orderTrain from "@/views/dnf/orderTrain.vue";


// Vue.use(VueRouter);

const err401 = r =>
    require.ensure([], () => r(require("../views/error/err401.vue")), "home");
const err404 = r =>
    require.ensure([], () => r(require("../views/error/err404.vue")), "home");
const login = r =>
    require.ensure([], () => r(require("../views/login/index.vue")), "home");
const main = r =>
    require.ensure([], () => r(require("../views/dnf/Im.vue")), "home");
const extraApply = r =>
    require.ensure([], () => r(require("../views/dnf/extraApply.vue")), "home");
const chargeConfig = r =>
    require.ensure([], () => r(require("../views/dnf/chargeConfig.vue")), "home");
const userBill = r =>
    require.ensure([], () => r(require("../views/dnf/UserBill.vue")), "home");

// 注意 权限字段 authRule （严格区分大小写）
export const constantRouterMap = [
    {
        path: "*",
        component: err404,
        hidden: true
    },
    {
        path: "/401",
        component: err401,
        name: "401",
        hidden: true
    },
    {
        path: "/404",
        component: err404,
        name: "404",
        hidden: true
    },
    {
        path: "/500",
        component: err404,
        name: "500",
        hidden: true
    },
    {
        path: "/login",
        component: login,
        name: "登录",
        hidden: true
    },
    {
        path: "/",
        component: Home,
        redirect: "/total",
        name: "首页",
        hidden: true
    },
    {
        path: "/total",
        component: Home,
        redirect: "/total/total",
        icon: "tongjifenxi-xiangmubiaogetongji",
        name: "成交量统计",
        noDropdown: true,
        meta: {
            authRule: ["total"]
        },
        children: [
            {
                path: "total",
                component: total,
            }
        ]
    }
];

export default new VueRouter({
    // mode: 'history', //后端支持可开
    mode: ROUTER_MODE,
    routes: constantRouterMap,
    strict: process.env.NODE_ENV !== "production"
});

export const asyncRouterMap = [
    {
        path: "/dnfim",
        component: Home,
        redirect: "/dnfim/im",
        icon: "liaotian1",
        name: "聊天室",
        meta: {
            authRule: ["dnfim"]
        },
        noDropdown: true,
        children: [
            {
                meta: {
                    authRule: ["dnfim"]
                },
                path: "im",
                component: main
            }
        ]
    },
    {
        path: "/dnf_manage_t",
        redirect: "/dnf_manage/train",
        component: Home,
        icon: "dailian",
        name: "游戏代练",
        meta: {
            authRule: ["dnf_train"]
        },
        // noDropdown: true,
        children: [
            {
                path: "train",
                component: training,
                name: "代练管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
        ]
    },
    {
        path: "/dnf",
        component: Home,
        redirect: "/dnf/extra",
        icon: "jinbitixian",
        name: "提现申请",
        meta: {
            authRule: ["extra"]
        },
        noDropdown: true,
        children: [
            {
                path: "extra",
                component: extraApply
            }
        ]
    },
    {
        path: "/dnf",
        component: Home,
        redirect: "/dnf/bill",
        icon: "tixian",
        name: "资金明细",
        noDropdown: true,
        meta: {
            authRule: ["user_bill"]
        },
        children: [
            {
                path: "bill",
                component: userBill
            }
        ]
    },
    {
        path: "/dnf",
        component: Home,
        redirect: "/dnf/charge",
        icon: "shouxufei",
        name: "手续费管理",
        meta: {
            authRule: ["charge"]
        },
        noDropdown: true,
        children: [
            {
                path: "charge",
                component: chargeConfig
            }
        ]
    },
    {
        path: "/dnf_gold",
        redirect: "/dnf_gold/gold_coin_self",
        component: Home,
        icon: "taojinbi",
        name: "金币材料管理",
        meta: {
            authRule: ["dnf_gold"]
        },
        // noDropdown: true,
        children: [

            {
                path: "gold_coin_self",
                component: goldCoinSelf,
                name: "DNF自营金币管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "gold_coin_shop",
                component: goldCoinShop,
                name: "DNF自营金币回收",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "gold_coin_s1",
                component: goldCoinS1,
                name: "DNF特价金币500",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "gold_coin_s3",
                component: goldCoinS3,
                name: "DNF特价金币5000",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "gold_coin_s2",
                component: goldCoinS2,
                name: "DNF特价金币回收500",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },

            {
                path: "gold_coin_s4",
                component: goldCoinS4,
                name: "DNF特价金币回收3000",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "gold_coin_proxy",
                component: goldCoinProxy,
                name: "DNF代理金币管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },{
                path: "gold_coin_md",
                component: goldCoinMd,
                name: "DNF矛盾管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            }, {
                path: "gold_coin_md_2",
                component: goldCoinMd2,
                name: "DNF矛盾回收管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "gold_coin_md_proxy",
                component: goldCoinMdProxy,
                name: "DNF矛盾代理管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },


        ]
    },
    {
        path: "/dnf_jade",
        redirect: "/dnf_jade/gold_coin_self",
        component: Home,
        icon: "yushi",
        name: "辟邪玉管理",
        meta: {
            authRule: ["dnf_jade"]
        },
        // noDropdown: true,
        children: [
            {
                path: "jade_self",
                component: jadeSelf,
                name: "DNF自营辟邪玉管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "jade_proxy",
                component: jadeProxy,
                name: "DNF担保辟邪玉管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },

        ]
    },
    {
        path: "/dnf_order",
        redirect: "/dnf_order/order",
        component: Home,
        icon: "dingdan",
        name: "订单管理",
        meta: {
            authRule: ["dnf_order"]
        },
        // noDropdown: true,
        children: [

            {
                path: "order",
                component: order,
                name: "自营金币订单管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "order2",
                component: order2,
                name: "回收金币订单管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "order3",
                component: order3,
                name: "担保金币订单管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "orderMd",
                component: orderMd,
                name: "自营矛盾订单管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "orderMd2",
                component: orderMd2,
                name: "回收矛盾订单管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "orderMdProxy",
                component: orderMdProxy,
                name: "担保矛盾订单管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "jadeOrder",
                component: orderJade,
                name: "担保辟邪玉订单管理",
                icon : "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },{
                path: "jadeOrderSelf",
                component: orderJadeSelf,
                name: "自营辟邪玉订单管理",
                icon : "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
            {
                path: "order_train",
                component: orderTrain,
                name: "DNF代练订单管理",
                icon: "",
                meta: {
                    // authRule: ["admin/ad/site/index"]
                }
            },
        ]
    },
    {
        path: "/userManage",
        redirect: "/userManage/adminManage/index",
        component: Home,
        icon: "user",
        name: "用户管理",
        meta: {
            authRule: ["user_manage"]
        },
        // noDropdown: true,
        children: [
            {
                path: "/userManage/adminManage",
                component: adminRouter,
                redirect: "/userManage/authAdmin/index",
                name: "管理组",
                icon: "",
                meta: {
                    authRule: ["user_manage/admin_manage"]
                },
                children: [
                    {
                        path: "authAdmin",
                        component: authAdmin,
                        name: "用户管理",
                        icon: "",
                        meta: {
                            authRule: ["admin/auth/admin/index"]
                        }
                    },
                    {
                        path: "authRole",
                        component: authRole,
                        name: "角色管理",
                        icon: "",
                        meta: {
                            authRule: ["admin/auth/role/index"]
                        }
                    },
                    {
                        path: "authPermissionRule",
                        component: authPermissionRule,
                        name: "权限管理",
                        icon: "",
                        meta: {
                            authRule: ["admin/auth/permission_rule/index"]
                        }
                    }
                ]
            }
        ]
    },
];
